package com.ymatou.iapi.alarm.testcase;

import java.util.Date;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.alarm.service.SaveSingleCall;
import com.ymatou.iapi.alarm.parameter.SaveSingleBean;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.utils.YMTDateUtil;
/**
*单个保存错误日志Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SaveSingle{
	private static SaveSingleBean savesingleBean;
	private static SaveSingleCall savesingleCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("单个保存错误日志Test");
	}

	@Before
	public void caseUp() {
		savesingleBean=new SaveSingleBean();
		savesingleCall=new SaveSingleCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(savesingleCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SaveSingle_001() {
		Logger.start(true,"单个保存错误日志,成功");
		try {
			savesingleBean.setAppId("AppId1");
			savesingleBean.setReqUrl(null);
			savesingleBean.setReqForm(null);
			savesingleBean.setErrorLevel("1");
			savesingleBean.setMethodName("自动化测试");
			savesingleBean.setAssemblyName("abc");
			savesingleBean.setTitle("Title");
			savesingleBean.setMessage("Message");
			savesingleBean.setExceptionName("ExceptionName");
			savesingleBean.setHeader(null);
			savesingleBean.setStackTrace(null);
			savesingleBean.setAddTime(YMTDateUtil.getSysTime());
			savesingleBean.setMachineIp(null);
			savesingleCall.setData(savesingleBean);
			savesingleCall.setData(FormatUtil.beanToHttpString(savesingleBean,true,false));
			savesingleCall.callService();	
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}